<template>
	<view class="main">
		<sp-guide v-if="guidePages" :homePageUrl="homePageUrl"></sp-guide>
	</view>
</template>

<script>
	import spGuide from '@/components/sp-guide/sp-guide.vue'
	export default {
		components: {
			spGuide
		},
		data() {
			return {
				guidePages: false,
				homePageUrl: '/pages/tabBars/home/index'
			}
		},
		onLoad() {
			this.loadExecution()
		},
		methods: {
			loadExecution: function() {
				if (getApp().globalData.enableGuide) {
					try {
						const value = uni.getStorageSync('launchFlag')
						if (value) {
							uni.switchTab({
								url: this.homePageUrl
							});
						} else {
							this.guidePages = true
						}
					} catch (e) {
						uni.setStorage({
							key: 'launchFlag',
							data: true,
							success: function() {
								console.log('error时存储launchFlag');
							}
						});
						this.guidePages = true
					}
					return;
				} else {
					uni.switchTab({
						url: this.homePageUrl
					});
				}

			}
		}
	}
</script>

<style>
	page,
	.main {
		width: 100%;
		height: 100%;
	}
</style>
